#define DEBUG
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=1000000, maxm=1000000, maxk=20;

class Point {
public:
  int x, y, v;

  bool operator<(Point &b) {return x<b.x;}
};

class ST {
public:
  int log2[maxn+1], v[maxn+1][maxk+1];

  void init(int n, int a[]) {
    log2[1] = 0;
    for (int i=2; i<=n; i++) log2[i] = log2[i/2]+1;

    for (int i=1; i<=n; i++) v[i][0] = a[i];
    for (int i=1; i<=log2[n]; i++) {
      for (int j=1; j<=n; j++) {
        if (j+(1<<(i-1))<=n) v[j][i] = min(v[j][i-1], v[j+(1<<(i-1))][i-1]);
        else v[j][i] = v[j][i-1];
      }
    }
  }

  int get(int l, int r) {
    int t=log2[r-l+1];
    return min(v[l][t], v[r-(1<<t)+1][t]);
  }
};

class SegmentTree {
public:
  int v[4*maxn+1];

  void setMax(int o, int l, int r, int t, int tv) {
    if (l==r) {
      v[o] = max(v[o], tv);
    } else {
      int mid=(l+r)/2;
      if (t<=mid) setMax(o*2, l, mid, t, tv);
      else setMax(o*2+1, mid+1, r, t, tv);
      v[o] = v[o*2]+v[o*2+1];
    }
  }

  int get(int o, int l, int r, int tl, int tr) {
    if (l==tl && r==tr) {
      return v[o];
    } else {
      int mid=(l+r)/2, ret=0;
      if (tl<=mid) ret += get(o*2, l, mid, tl, min(tr, mid));
      if (tr>mid) ret += get(o*2+1, mid+1, r, max(tl, mid+1), tr);
      return ret;
    }
  }
};

void makePoints(int n, int a[], int &m, Point p[]) {
  static ST st;
  st.init(n, a);
  
  m = 0;
  for (int i=1; i<=n; i++) {
    int maxt=st.get(1, i);
    for (int j=1; i*j<=n+i-1; j++) {
      maxt = max(maxt, st.get(i*j-i+1, min(n, i*j)));
      p[++m].x = maxt;
      p[m].y = i;
      p[m].v = j;
    }
  
}
}

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static int ser[maxn+1], ques[maxm+1][3], ans[maxm+1]; //servant
  int n, m, time=0, cntq=0;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=n; i++) ser[i] = m+1;
  for (int i=1; i<=m; i++) {
    int typ, t;
    scanf("%d", &typ);
    if (typ==1) {
      scanf("%d", &t);
      ser[t] = min(ser[t], ++time);
    } else {
      cntq++;
      scanf("%d %d", ques[cntq]+1, ques[cntq]+2);
      ques[cntq][0] = time;
    }
  }

  static Point ps[maxn*maxk+1];
  int pn=0;
  makePoints(n, ser, pn, ps);
  sort(ps+1, ps+pn+1);

  static SegmentTree sgt;
  for (int i=1, j=1; i<=cntq; i++) {
    for (; ps[j].x<=ques[i][0]; j++) sgt.setMax(1, 1, n, ps[j].y, ps[j].v);
    ans[i] = sgt.get(1, 1, n, ques[i][1], ques[i][2])+ques[i][2]-ques[i][1]+1;
  }

  for (int i=1; i<=cntq; i++) printf("%d\n", ans[i]);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
